package com.itheima.controller;

import com.itheima.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.List;

@Controller
@RequestMapping("/jsonparam")
@ResponseBody
public class ParamJsonController {
    /**
     * @RequestBody 帮助我们接收json格式的数据并自动封装
     * @param list
     * @return
     */
    @RequestMapping("/json1")
    public String json1(@RequestBody List<String> list) {
        System.out.println(list);
        return "{json1:hello}";
    }

    @RequestMapping("/json2")
    public String json2(@RequestBody User user) {
        System.out.println(user);
        return "{json2:hello}";
    }

    @RequestMapping("/json3")
    public String json3(@RequestBody List<User> list) {
        System.out.println(list);
        return "{json3:hello}";
    }
}
